package cn.tedu.stringx;

public class StringDemo2 {
    public static void main(String[] args) {
//        String str = "hello world!";
//        //charAt 获取str的第一个字符
//        char c = str.charAt(20);
////        System.out.println(c);
//        //遍历字符串 charAt()+length()
//        for (int i = 0; i <str.length() ; i++) {
//            System.out.println(str.charAt(i));
//        }

        //concat--字符串拼接
//        String str = "abc";
//        String res = str.concat("kkk");//new String()
//        String res1 = "abckkk";
//        System.out.println(res==res1);//false
//        System.out.println(str);//abc
//        System.out.println(res);//abckkk
//        //+  new StringBuilder().append("kkk")
//        System.out.println(str+"kkk");//反编译
//        String str = "start";
//        for (int i = 0; i < 1000; i++) {
//            str = str+i+",";//str+0+","
//        }
//        StringBuilder stringBuilder = new StringBuilder("start");
//        for (int i = 0; i < 1000; i++) {
//            stringBuilder.append(i).append(",");
//        }
//        StringBuilder builder = new StringBuilder("abc");
//        System.out.println(builder);
//        builder.append("kkk");
//        System.out.println(builder);

        //contains--字符串查找(作业)
        String str = "hello ho world";
        //判断str中是否包含hi
       boolean res =  str.contains("hi");
        System.out.println(res);
    }
}
